{smcl}
{txt}{sf}{ul off}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/2_Figure_D1.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}25 Jan 2022, 22:37:22
{txt}
{com}. 
. timer on 2
{txt}
{com}. 
. *------------*
. * Figure D.1 *
. *------------*
.         * Figure D.1.a
.         *-------------
.                 use "data/outputs/computo_verificadortrepdate_missingsatthend.dta", clear
{txt}
{com}. 
.                 * Recinto ID
.                 egen reci_id = group(Pais Dep Prov Muni Loc Reci)
{txt}
{com}.                         /* Note, in constructing the data set we made a correction
>                            such that recinto names are unique within localities. */
. 
.                 * Number of mesas
.                 egen nmesas = count(mshare_nbnn), by(reci_id)
{txt}
{com}. 
.                 * Margin
.                 gen margin_nbnn = mshare_nbnn - cshare_nbnn
{txt}(4 missing values generated)

{com}. 
.                 * Cutoff
.                 quietly sum pcs_nbnn if trep_date_verificador >= tc(20oct2019 19:40:57) & ///
>                         trep_date_verificador <= tc(20oct2019 19:40:58), detail
{txt}
{com}.                 local cutoff = `r(min)' 
{txt}
{com}.                 local label = round(`cutoff', .01)
{txt}
{com}. 
.                 gen chosen_reci = (Dep == "Potosí" & Muni == "Llallagua" & ///
>                         Reci == "Col. 1ro. De Mayo")
{txt}
{com}. 
.                 lprobust margin_nbnn pcs_nbnn, genvars
{res}
Local Polynomial Regression Estimation and Inference.

{txt}{lalign 1: Sample size                              (n=)    }{col 19}{res}          34551
{txt}{lalign 1: Polynomial order for point estimation    (p=)    }{col 19}{res}              1
{txt}{lalign 1: Order of derivative estimated            (v=)    }{col 19}{res}              0
{txt}{lalign 1: Polynomial order for confidence interval (q=)    }{col 19}{res}              2
{txt}{lalign 1: Kernel function                                  }{col 19}{res}{ralign 15: Epanechnikov}
{txt}{lalign 1: Bandwidth selection method                       }{col 19}{res}{ralign 15: imse-dpi}

{txt}{hline 72}
{ralign 4: }{col 4}{ralign 10: }{col 14}{ralign 10: }{col 24}{ralign 8: }{col 32}{ralign 10: Point}{col 42}{ralign 10: Std.}{col 52}{ralign 20: Robust B.C.}{col 72}
{ralign 4: }{col 4}{ralign 10: eval}{col 14}{ralign 10: bw}{col 24}{ralign 8: Eff.n}{col 32}{ralign 10: Est.}{col 42}{ralign 10: Error}{col 52}{ralign 20: 95% Conf. Interval}{col 72}
{hline 72}
   1{col 4}{res}    0.0152{col 14}    0.0849{col 24}    4530{col 32}    0.0759{col 42}    0.0099{col 52}    0.0566{col 62}    0.0953{col 72}
{txt}   2{col 4}{res}    0.0382{col 14}    0.0849{col 24}    5339{col 32}    0.0541{col 42}    0.0074{col 52}    0.0395{col 62}    0.0791{col 72}
{txt}   3{col 4}{res}    0.0674{col 14}    0.0849{col 24}    6339{col 32}    0.0317{col 42}    0.0065{col 52}   -0.0040{col 62}    0.0349{col 72}
{txt}   4{col 4}{res}    0.0981{col 14}    0.0849{col 24}    6404{col 32}    0.0133{col 42}    0.0067{col 52}   -0.0201{col 62}    0.0175{col 72}
{txt}   5{col 4}{res}    0.1299{col 14}    0.0849{col 24}    5937{col 32}    0.0125{col 42}    0.0067{col 52}   -0.0072{col 62}    0.0310{col 72}
{txt}{hline 72}
   6{col 4}{res}    0.1626{col 14}    0.0849{col 24}    5819{col 32}    0.0210{col 42}    0.0067{col 52}   -0.0012{col 62}    0.0371{col 72}
{txt}   7{col 4}{res}    0.1955{col 14}    0.0849{col 24}    5734{col 32}    0.0329{col 42}    0.0066{col 52}    0.0128{col 62}    0.0498{col 72}
{txt}   8{col 4}{res}    0.2287{col 14}    0.0849{col 24}    5695{col 32}    0.0494{col 42}    0.0065{col 52}    0.0277{col 62}    0.0646{col 72}
{txt}   9{col 4}{res}    0.2621{col 14}    0.0849{col 24}    5655{col 32}    0.0647{col 42}    0.0065{col 52}    0.0542{col 62}    0.0909{col 72}
{txt}  10{col 4}{res}    0.2955{col 14}    0.0849{col 24}    5632{col 32}    0.0752{col 42}    0.0064{col 52}    0.0637{col 62}    0.0999{col 72}
{txt}{hline 72}
  11{col 4}{res}    0.3295{col 14}    0.0849{col 24}    5608{col 32}    0.0822{col 42}    0.0063{col 52}    0.0600{col 62}    0.0952{col 72}
{txt}  12{col 4}{res}    0.3634{col 14}    0.0849{col 24}    5585{col 32}    0.0879{col 42}    0.0063{col 52}    0.0642{col 62}    0.0998{col 72}
{txt}  13{col 4}{res}    0.3973{col 14}    0.0849{col 24}    5562{col 32}    0.0945{col 42}    0.0063{col 52}    0.0827{col 62}    0.1188{col 72}
{txt}  14{col 4}{res}    0.4312{col 14}    0.0849{col 24}    5553{col 32}    0.1050{col 42}    0.0063{col 52}    0.0849{col 62}    0.1204{col 72}
{txt}  15{col 4}{res}    0.4655{col 14}    0.0849{col 24}    5545{col 32}    0.1185{col 42}    0.0063{col 52}    0.0916{col 62}    0.1266{col 72}
{txt}{hline 72}
  16{col 4}{res}    0.4997{col 14}    0.0849{col 24}    5543{col 32}    0.1328{col 42}    0.0063{col 52}    0.1202{col 62}    0.1561{col 72}
{txt}  17{col 4}{res}    0.5340{col 14}    0.0849{col 24}    5559{col 32}    0.1505{col 42}    0.0064{col 52}    0.1342{col 62}    0.1707{col 72}
{txt}  18{col 4}{res}    0.5681{col 14}    0.0849{col 24}    5568{col 32}    0.1637{col 42}    0.0064{col 52}    0.1462{col 62}    0.1825{col 72}
{txt}  19{col 4}{res}    0.6022{col 14}    0.0849{col 24}    5591{col 32}    0.1672{col 42}    0.0064{col 52}    0.1594{col 62}    0.1955{col 72}
{txt}  20{col 4}{res}    0.6355{col 14}    0.0849{col 24}    5572{col 32}    0.1602{col 42}    0.0064{col 52}    0.1563{col 62}    0.1925{col 72}
{txt}{hline 72}
  21{col 4}{res}    0.6694{col 14}    0.0849{col 24}    5561{col 32}    0.1603{col 42}    0.0062{col 52}    0.1150{col 62}    0.1510{col 72}
{txt}  22{col 4}{res}    0.7032{col 14}    0.0849{col 24}    5546{col 32}    0.1655{col 42}    0.0059{col 52}    0.1542{col 62}    0.1871{col 72}
{txt}  23{col 4}{res}    0.7382{col 14}    0.0849{col 24}    5538{col 32}    0.1437{col 42}    0.0058{col 52}    0.1780{col 62}    0.2100{col 72}
{txt}  24{col 4}{res}    0.7721{col 14}    0.0849{col 24}    5537{col 32}    0.1283{col 42}    0.0059{col 52}    0.0838{col 62}    0.1185{col 72}
{txt}  25{col 4}{res}    0.8067{col 14}    0.0849{col 24}    5575{col 32}    0.1279{col 42}    0.0061{col 52}    0.0436{col 62}    0.0769{col 72}
{txt}{hline 72}
  26{col 4}{res}    0.8403{col 14}    0.0849{col 24}    5616{col 32}    0.1631{col 42}    0.0061{col 52}    0.1541{col 62}    0.1897{col 72}
{txt}  27{col 4}{res}    0.8741{col 14}    0.0849{col 24}    5718{col 32}    0.2422{col 42}    0.0061{col 52}    0.2287{col 62}    0.2632{col 72}
{txt}  28{col 4}{res}    0.9073{col 14}    0.0849{col 24}    5879{col 32}    0.2908{col 42}    0.0059{col 52}    0.3035{col 62}    0.3362{col 72}
{txt}  29{col 4}{res}    0.9395{col 14}    0.0849{col 24}    5100{col 32}    0.3029{col 42}    0.0063{col 52}    0.3343{col 62}    0.3688{col 72}
{txt}  30{col 4}{res}    0.9705{col 14}    0.0849{col 24}    4073{col 32}    0.2785{col 42}    0.0091{col 52}    0.2791{col 62}    0.3162{col 72}
{txt}{hline 72}

{com}. 
.                 twoway (line lprobust_gx_bc lprobust_eval, ///
>                                 lcolor(gs6) lwidth(medthick)) ///
>                         (line lprobust_CI_l_rb lprobust_eval, ///
>                                 lcolor(gs6) lwidth(thin) lpattern(dash)) ///
>                         (line lprobust_CI_r_rb lprobust_eval, ///
>                                 lcolor(gs6) lwidth(thin) lpattern(dash)) ///
>                         (scatter margin_nbnn pcs_nbnn if chosen_reci == 1, mcolor(midblue) ///
>                                 msize(small) msymbol(Dh)) /// 
>                         (lfit margin_nbnn pcs_nbnn if chosen_reci == 1, lcolor(midblue) ///
>                                 lwidth(medthick)), ///
>                         graphregion(color(white)) ///
>                         xline(`cutoff', lcolor(black) lpattern(dash)) ///
>                         ylab(, glcolor(none) angle(0)) ///
>                         xlab(0 `cutoff' "`label'" 1) ///
>                         ytitle("MAS Vote Margin") ///
>                         xtitle("Proportion of Preliminary Vote Counted") ///
>                         xsize(7) ysize(5) ///
>                         legend(pos(11) ring(0) rows(3) symxsize(*.4) ///
>                         order(4 "Voting booths from one" "precinct (example)" ///
>                                 1 "Overall vote margin trend"))
{res}{txt}
{com}.                 graph export "outputs/generated/Figure_D1a.pdf", replace
{txt}(file outputs/generated/Figure_D1a.pdf written in PDF format)

{com}. 
.         * Figure D.1.b
.         *-------------
.                 use "data/outputs/computo_verificadortrepdate_missingsatthend.dta", clear       
{txt}
{com}. 
.                 * Nulos share
.                 gen nulosshare = Nulos / total_so
{txt}(4 missing values generated)

{com}. 
.                 * Margin
.                 gen margin_nbnn = mshare_nbnn - cshare_nbnn
{txt}(4 missing values generated)

{com}. 
.                 * Recinto ID
.                 egen reci_id = group(Pais Dep Prov Muni Loc Reci)
{txt}
{com}. 
.                 foreach var of varlist mshare_nbnn cshare_nbnn margin_nbnn nulosshare {c -(}
{txt}  2{com}.                         egen reci_mean = mean(`var'), by(reci_id)
{txt}  3{com}.                         gen `var'_dm = `var' - reci_mean 
{txt}  4{com}.                         drop reci_mean
{txt}  5{com}.                         qui su `var'
{txt}  6{com}.                         gen `var'_dm_plus = `var'_dm + `r(mean)' // Add overall mean for scale
{txt}  7{com}.                 {c )-}
{txt}(4 missing values generated)
(4 missing values generated)
(4 missing values generated)
(4 missing values generated)
(4 missing values generated)
(4 missing values generated)
(4 missing values generated)
(4 missing values generated)

{com}.         
.                 * Cutoff
.                 quietly sum pcs_nbnn if trep_date_verificador >= tc(20oct2019 19:40:57) & ///
>                         trep_date_verificador <= tc(20oct2019 19:40:58), detail
{txt}
{com}.                 local cutoff = `r(min)' 
{txt}
{com}.                 local label = round(`cutoff', .01)
{txt}
{com}. 
.                 binsreg margin_nbnn_dm pcs_nbnn, savedata(temp) replace
{txt}Sorting dataset on pcs_nbnn_so...
Note: This step is omitted if dataset already sorted by pcs_nbnn_so.
{res}
{txt}Binscatter plot
Bin selection method: IMSE-optimal plug-in choice
Placement: Quantile-spaced
Derivative: 0
Output file: temp.dta

{hline 30}{c TT}{hline 15}
{lalign 1:# of observations}{col 30} {c |} {col 32}{res}  34551
{txt}{lalign 1:# of distinct values}{col 30} {c |} {col 32}{res}  34551
{txt}{lalign 1:# of clusters}{col 30} {c |} {col 32}{res}      .
{txt}{hline 30}{c +}{hline 15}
{lalign 1:Bin selection:}{col 30} {c |} 
{ralign 29:Degree of polynomial}{col 30} {c |} {col 32}{res}      0
{txt}{ralign 29:# of smoothness constraints}{col 30} {c |} {col 32}{res}      0
{txt}{ralign 29:# of bins}{col 30} {c |} {col 32}{res}     45
{txt}{hline 30}{c BT}{hline 15}

{hline 9}{c TT}{hline 30}
{col 10}{c |}{col 17}p{col 25}s{col 33}df
{hline 9}{c +}{hline 30}
{lalign 1: dots}{col 10}{c |}{col 17}0{col 25}0{col 33}45
{hline 9}{c BT}{hline 30}
{res}{txt}
{com}. 
.                 gen dots_binid = _n
{txt}
{com}.                 merge 1:1 dots_binid using "temp.dta"
{res}
{txt}{col 5}Result{col 38}# of obs.
{col 5}{hline 41}
{col 5}not matched{col 30}{res}          34,510
{txt}{col 9}from master{col 30}{res}          34,510{txt}  (_merge==1)
{col 9}from using{col 30}{res}               0{txt}  (_merge==2)

{col 5}matched{col 30}{res}              45{txt}  (_merge==3)
{col 5}{hline 41}

{com}.                 drop _merge
{txt}
{com}.                 erase "temp.dta"
{txt}
{com}. 
.                 lprobust margin_nbnn_dm pcs_nbnn, genvars
{res}
Local Polynomial Regression Estimation and Inference.

{txt}{lalign 1: Sample size                              (n=)    }{col 19}{res}          34551
{txt}{lalign 1: Polynomial order for point estimation    (p=)    }{col 19}{res}              1
{txt}{lalign 1: Order of derivative estimated            (v=)    }{col 19}{res}              0
{txt}{lalign 1: Polynomial order for confidence interval (q=)    }{col 19}{res}              2
{txt}{lalign 1: Kernel function                                  }{col 19}{res}{ralign 15: Epanechnikov}
{txt}{lalign 1: Bandwidth selection method                       }{col 19}{res}{ralign 15: imse-dpi}

{txt}{hline 72}
{ralign 4: }{col 4}{ralign 10: }{col 14}{ralign 10: }{col 24}{ralign 8: }{col 32}{ralign 10: Point}{col 42}{ralign 10: Std.}{col 52}{ralign 20: Robust B.C.}{col 72}
{ralign 4: }{col 4}{ralign 10: eval}{col 14}{ralign 10: bw}{col 24}{ralign 8: Eff.n}{col 32}{ralign 10: Est.}{col 42}{ralign 10: Error}{col 52}{ralign 20: 95% Conf. Interval}{col 72}
{hline 72}
   1{col 4}{res}    0.0152{col 14}    0.4007{col 24}   15102{col 32}   -0.0032{col 42}    0.0014{col 52}   -0.0058{col 62}    0.0014{col 72}
{txt}   2{col 4}{res}    0.0382{col 14}    0.4007{col 24}   15858{col 32}   -0.0031{col 42}    0.0013{col 52}   -0.0055{col 62}    0.0001{col 72}
{txt}   3{col 4}{res}    0.0674{col 14}    0.4007{col 24}   16805{col 32}   -0.0029{col 42}    0.0011{col 52}   -0.0051{col 62}   -0.0007{col 72}
{txt}   4{col 4}{res}    0.0981{col 14}    0.4007{col 24}   17804{col 32}   -0.0027{col 42}    0.0010{col 52}   -0.0048{col 62}   -0.0009{col 72}
{txt}   5{col 4}{res}    0.1299{col 14}    0.4007{col 24}   18841{col 32}   -0.0026{col 42}    0.0009{col 52}   -0.0046{col 62}   -0.0009{col 72}
{txt}{hline 72}
   6{col 4}{res}    0.1626{col 14}    0.4007{col 24}   19908{col 32}   -0.0024{col 42}    0.0008{col 52}   -0.0045{col 62}   -0.0007{col 72}
{txt}   7{col 4}{res}    0.1955{col 14}    0.4007{col 24}   20985{col 32}   -0.0022{col 42}    0.0007{col 52}   -0.0043{col 62}   -0.0005{col 72}
{txt}   8{col 4}{res}    0.2287{col 14}    0.4007{col 24}   22093{col 32}   -0.0019{col 42}    0.0007{col 52}   -0.0040{col 62}   -0.0002{col 72}
{txt}   9{col 4}{res}    0.2621{col 14}    0.4007{col 24}   23189{col 32}   -0.0017{col 42}    0.0007{col 52}   -0.0038{col 62}   -0.0000{col 72}
{txt}  10{col 4}{res}    0.2955{col 14}    0.4007{col 24}   24299{col 32}   -0.0014{col 42}    0.0006{col 52}   -0.0035{col 62}    0.0002{col 72}
{txt}{hline 72}
  11{col 4}{res}    0.3295{col 14}    0.4007{col 24}   25373{col 32}   -0.0011{col 42}    0.0006{col 52}   -0.0031{col 62}    0.0005{col 72}
{txt}  12{col 4}{res}    0.3634{col 14}    0.4007{col 24}   26490{col 32}   -0.0008{col 42}    0.0006{col 52}   -0.0027{col 62}    0.0009{col 72}
{txt}  13{col 4}{res}    0.3973{col 14}    0.4007{col 24}   27587{col 32}   -0.0005{col 42}    0.0006{col 52}   -0.0023{col 62}    0.0013{col 72}
{txt}  14{col 4}{res}    0.4312{col 14}    0.4007{col 24}   26801{col 32}   -0.0002{col 42}    0.0006{col 52}   -0.0019{col 62}    0.0017{col 72}
{txt}  15{col 4}{res}    0.4655{col 14}    0.4007{col 24}   26586{col 32}    0.0001{col 42}    0.0006{col 52}   -0.0016{col 62}    0.0020{col 72}
{txt}{hline 72}
  16{col 4}{res}    0.4997{col 14}    0.4007{col 24}   26491{col 32}    0.0004{col 42}    0.0006{col 52}   -0.0013{col 62}    0.0022{col 72}
{txt}  17{col 4}{res}    0.5340{col 14}    0.4007{col 24}   26470{col 32}    0.0006{col 42}    0.0006{col 52}   -0.0010{col 62}    0.0025{col 72}
{txt}  18{col 4}{res}    0.5681{col 14}    0.4007{col 24}   26526{col 32}    0.0009{col 42}    0.0006{col 52}   -0.0007{col 62}    0.0028{col 72}
{txt}  19{col 4}{res}    0.6022{col 14}    0.4007{col 24}   26553{col 32}    0.0011{col 42}    0.0006{col 52}   -0.0004{col 62}    0.0031{col 72}
{txt}  20{col 4}{res}    0.6355{col 14}    0.4007{col 24}   25435{col 32}    0.0013{col 42}    0.0006{col 52}   -0.0001{col 62}    0.0035{col 72}
{txt}{hline 72}
  21{col 4}{res}    0.6694{col 14}    0.4007{col 24}   24301{col 32}    0.0015{col 42}    0.0006{col 52}    0.0002{col 62}    0.0038{col 72}
{txt}  22{col 4}{res}    0.7032{col 14}    0.4007{col 24}   23176{col 32}    0.0017{col 42}    0.0006{col 52}    0.0004{col 62}    0.0041{col 72}
{txt}  23{col 4}{res}    0.7382{col 14}    0.4007{col 24}   22030{col 32}    0.0019{col 42}    0.0007{col 52}    0.0006{col 62}    0.0043{col 72}
{txt}  24{col 4}{res}    0.7721{col 14}    0.4007{col 24}   20917{col 32}    0.0020{col 42}    0.0007{col 52}    0.0007{col 62}    0.0045{col 72}
{txt}  25{col 4}{res}    0.8067{col 14}    0.4007{col 24}   19778{col 32}    0.0022{col 42}    0.0007{col 52}    0.0007{col 62}    0.0044{col 72}
{txt}{hline 72}
  26{col 4}{res}    0.8403{col 14}    0.4007{col 24}   18675{col 32}    0.0022{col 42}    0.0008{col 52}    0.0006{col 62}    0.0042{col 72}
{txt}  27{col 4}{res}    0.8741{col 14}    0.4007{col 24}   17578{col 32}    0.0023{col 42}    0.0009{col 52}    0.0006{col 62}    0.0041{col 72}
{txt}  28{col 4}{res}    0.9073{col 14}    0.4007{col 24}   16498{col 32}    0.0023{col 42}    0.0010{col 52}    0.0004{col 62}    0.0042{col 72}
{txt}  29{col 4}{res}    0.9395{col 14}    0.4007{col 24}   15450{col 32}    0.0023{col 42}    0.0011{col 52}   -0.0002{col 62}    0.0045{col 72}
{txt}  30{col 4}{res}    0.9705{col 14}    0.4007{col 24}   14435{col 32}    0.0022{col 42}    0.0013{col 52}   -0.0012{col 62}    0.0051{col 72}
{txt}{hline 72}

{com}.         
.                 twoway (scatter dots_fit dots_x, msize(small) mcolor(midblue)) ///
>                         (line lprobust_gx_bc lprobust_eval, ///
>                                 lcolor(gs6) lwidth(medthick)) ///
>                         (line lprobust_CI_l_rb lprobust_eval, ///
>                                 lcolor(gs6) lwidth(thin) lpattern(dash)) ///
>                         (line lprobust_CI_r_rb lprobust_eval, ///
>                                 lcolor(gs6) lwidth(thin) lpattern(dash)), ///
>                         graphregion(color(white)) ///
>                         xline(`cutoff', lcolor(black) lpattern(dash)) ///
>                         ylab(, glcolor(none) angle(0)) ///
>                         xlab(0 `cutoff' "`label'" 1) ///
>                         ytitle("MAS Margin Minus Precinct Mean") ///
>                         xtitle("Proportion of Preliminary Vote Counted") ///
>                         xsize(7) ysize(5) ///
>                         legend(off)
{res}{txt}
{com}.                 graph export "outputs/generated/Figure_D1b.pdf", replace
{txt}(file outputs/generated/Figure_D1b.pdf written in PDF format)

{com}. 
. *------------------------------------------------------------------------------*
. timer off 2
{txt}
{com}. timer list 2
{res}   2:     58.74 /        1 =      58.7360
{txt}
{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}E:\Github\Bolivia\00_replication_files\log-files/2_Figure_D1.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}25 Jan 2022, 22:38:21
{txt}{.-}
{smcl}
{txt}{sf}{ul off}